<?php if (isset($project)) { ?>
    
    

    <?php if (isset($SprintStories)){
        echo '<h1>'.'Sprint '.($this->params['pass'][1] + 1).': '.$this->Html->link(h($project['Project']['name']),'view/'.$project['Project']['id']).'</h1>';
       
    }
    else{
         ?>
                    <?php
                    echo '<h1>Proyecto :'.$this->Html->link(h($project['Project']['name']),'view/'.$project['Project']['id']).'</h1>';
                    
         
    }?>
                
         
         
         <a href="<?php echo $this->base; ?>/projects/backlog/<?php echo $project['Project']['id'];  if (isset($SprintStories))echo '/'.($this->params['pass'][1]);?>" 
            class="btn btn-inverse pull-right"
            rel="tooltip" title="Vista Lista">
            <i class="icon-th-list icon-white"></i>
         </a>

         <a href="<?php echo $this->base; ?>/projects/backlogGrid/<?php echo $project['Project']['id']; if (isset($SprintStories))echo '/'.($this->params['pass'][1]); ?>" 
            class="btn btn-inverse pull-right"
            rel="tooltip" title="Vista Grilla">
             <i class="icon-th icon-white"></i>
         </a>
             
         <?php
         
    
    ?>
    <?php if (!isset($SprintStories)){?>
        <p><small>Created: <?php echo $project['Project']['created']; ?></small></p>
        <p><?php echo h($project['Project']['description']); ?></p>
    <?php }  else {
        echo '<p></p><br/><p></p>';
    }?>
    
    <?php if (isset($SprintStories)){
        $project['Story']=$SprintStories;
    }
    ?>
    <div class="row-fluid">
        <div class="span12">
                <div class="span9">
                </div>
                    <?php
                    echo $this->element('stories/addStory',array('from'=> '3'));
                    ?>
         </div>
    
    <br/><br/><br/><br/>
        
        <?php
       
       
        
        ?>
        <br/>

        <div class="row-fluid">
                
                <div class="span12">
                    <div id="myCarousel" class="carousel slide">
                        <?php 

                            for ($i=0; $i<count($stories);$i++){    

                            if (isset($SprintStories))

                                ?>
                                <div class="item <?php if($i==0) echo 'active';?>">
                                    <div class="span12">
                                        <div class="span2">
                                            <br/>
                                            <?php  if($i>0){?>
                                            <div class="well" style="color: #999;">
                                                    <p> 
                                                        <strong> <?php echo $i;?> </strong>

                                                        <?php echo $stories[$i-1]['Story']['summary']?> 
                                                        <br/>
                                                        
                                                        <?php echo 'Sprint: '.($stories[$i]['Story']['sprint']); ?>
                                                    </p>
                                                    
                                            </div>
                                            <?php }?>
                                        </div>
                                        <div class="span8">
                                            <?php if (!isset($stories[$i]['color']))
                                                        $stories[$i]['Story']['color']='#FFF';

                                            if (($stories[$i]['Story']['color'])=="")
                                                        $stories[$i]['Story']['color']='#FFF';
                                                    ?>
                                            <div class="bs-docs-example" style="background-color:<?php echo $stories[$i]['Story']['color']?>; " id ="<?php echo $i;?>">
                                                <ul class="nav nav-pills pull-right">
                                                     <?php if ($permiso){?>
                                                    <li>
                                                        <a data-toggle="modal" href="#editStory<?php echo $stories[$i]['Story']['id'] ?>" role="button"  ><i class="icon-edit"></i></a>
                                                        <?php 
                                                            echo $this->element('stories/editStory',array("story" => $stories[$i]['Story'],"pSprints" => $project['Project']['sprints'],"from"=>4,"members"=>$members));

                                                        ?>
                                                     </li>
                                                     <?php } ?>
                                                     <li>
                                                        <a data-toggle="modal" href="#pokerStory<?php echo $stories[$i]['Story']['id'] ?>" role="button"  ><i class="icon-time"></i></a>
                                                        <?php
                                                            echo $this->element('stories/pokerStory',array("story" => $stories[$i],"from"=>4));

                                                        ?>
                                                    </li>
                                                     <?php if ($permiso){?>
                                                    <li>
                                                    <?php echo $this->Form->postLink(
                                                                    '<i class="icon-trash"></i>', //le image
                                                                    '/stories/delete/'.$stories[$i]['Story']['id'].'/1', //,le url
                                                                    array('escape' => false,'confirm' => 'Are you sure?','class' => 'nav-pills'));

                                                                ?>   
                                                    </li>
                                                    <?php } ?>
                                                    <li>
<!--                                                        <a class="input-append color" data-color="<?php echo $stories[$i]['Story']['color']?>" value="<?php echo $stories[$i]['Story']['color']?>" data-color-format="rgb"  id="color<?php echo $i;?>">
                                                            <span class="add-on" style="padding:0px; border: none;height: auto;"><i style="background-color: rgb(255, 146, 180)"> </i></span>
                                                        </a>-->
                                                    <a class="input-append color" data-color="<?php echo $stories[$i]['Story']['color']?>" data-color-format="hex" id="color<?php echo $i;?>">
                                                        <span class="add-on" style="padding:0px; border: none;height: auto;"><i class="icon-tint"></i></span>
                                                    </a>

                                                    </li>
                                                </ul>
                                                <p> 
                                                    <?php echo $this->Html->link($i+1,array('controller'=>'stories','action'=>'view', $stories[$i]['Story']['id'])); ?>

                                                    <?php echo ' '.$stories[$i]['Story']['summary']?> 
                                                    <br/><br/>
                                                    <?php echo $stories[$i]['Story']['detail']?> 
                                                    <br/><br/>
                                                    <?php echo $this->Html->link('Sprint: '.($stories[$i]['Story']['sprint']+1),'backlogCard/'.$project['Project']['id'].'/'.$stories[$i]['Story']['sprint']); ?>
                                                </p>
                                                <?php $j=$stories[$i]['Story']['state']; ?>
                                                <div class="progress progress-<?php 
                                                    if ($j==0)echo "danger";
                                                    if ($j==1)echo "warning";
                                                    if ($j==2)echo "info";
                                                    if ($j==3)echo "success";
                                                    ?>" style="height: 12px;  width: 50%;">
                                                    <div  class="bar" style="width: <?php 
                                                        if ($j==0)echo "0%";
                                                        if ($j==1)echo "36%";
                                                        if ($j==2)echo "66%";
                                                        if ($j==3)echo "100%";
                                                        ?>">
                                                    </div>
                                                </div>

                                            </div>
                                        </div>
                                        <div class="span2">
                                            <br/>
                                            <?php  if($i<(count($stories)-1)){?>
                                                <div class="well" style="color: #999;">
                                                    <p> 
                                                        <strong><?php echo $i+2;?></strong>

                                                        <?php echo $stories[$i]['Story']['summary']?> 
                                                        <br/>
                                                        
                                                        <?php echo 'Sprint: '.($stories[$i+1]['Story']['sprint']); ?>
                                                        
                                                    </p>
                                                    
                                                </div>
                                            <?php }?>
                                        </div>
                                    </div>
                                    
                                </div>
                           <?php  

                         }?>
                    <!--   Carousel nav -->
                    <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
                    <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
                    </div>
            </div>
        </div>
</div>
    
<?php } else {?>
    <br/>
    <div class="alert alert-info">
        Error de acceso.
    </div>
<?php }?>


